package com.merchant.document.controller.project;

import com.merchant.document.entity.Brand;
import com.merchant.document.entity.BrandExpand;
import com.merchant.document.entity.Project;
import com.merchant.document.entity.Result;
import com.merchant.document.util.SystemUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Api("项目")
public class ProjectController {


    @Autowired
    private SystemUtil systemUtil;

    @RequestMapping(value = "brand.project.toBaseInfo",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "跳转到发布项目的界面",notes = "转到发布项目的界面")
    public Result toBaseProjectInfo(){
         Map<String,Object> data = new HashMap<String,Object>();
         data.put("type1",systemUtil.getSysParaByType("1"));
         data.put("type2",systemUtil.getSysParaByType("2"));
         return new Result(true,"操作成功",data);
    }

    @RequestMapping(value = "brand.project.saveBaseInfo",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "保存项目的基本信息",notes = "保存项目的基本信息")
//    @ApiParam(name = "project",value="传入json格式",required = true,dataType="")
    public Result saveBaseProjectInfo(@RequestBody Project project){
         Map<String,Object> data = new HashMap<String,Object>();
         data.put("projectId","项目ID1");
        return  new Result(true,"保存成功",data);
    }

    @RequestMapping(value = "brand.project.saveProjectImgs",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "保存项目的图片",notes = "保存项目的图片")
    public Result saveProjectPics(InputStream is, String projectId){
        Map<String,Object> data = new HashMap<String,Object>();
        data.put("projectId","项目ID1");
        return  new Result(true,"保存成功",data);
    }

    @RequestMapping(value = "brand.project.saveMerchantsInfo",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "保存招商信息",notes = "保存招商信息")
    public Result saveMerchantsInfo(){
        return  new Result(true,"保存成功");
    }

    /**
     * 品牌商的功能
     */
    @RequestMapping(value = "project.brand.projectList",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查询推荐项目",notes = "查询推荐项目")
    public Result recomendProjectList(){
        Map<String,Object> data = new HashMap<String,Object>();
        //省略了推荐算法
        List<Project> projectList = new ArrayList<Project>();
        Project project = new Project();
        project.setCity("sssddlsfjsfl");
        projectList.add(project);
        projectList.add(new Project());
        data.put("area",systemUtil.getSysParaByType("area"));
        //项目区域，
        data.put("projectArea",systemUtil.getSysParaByType("area"));
        return  new Result(true,"操作成功",projectList);
    }

    @RequestMapping(value = "project.brand.getProjectListByName",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "通过名称来查询项目信息",notes = "通过名称来查询项目信息")
    @ApiImplicitParam(name = "projectName",value = "项目名称",dataType = "java.util.string")
    public Result getProjectListByName(String projectName){
        List<Project> projectList = new ArrayList<Project>();
        projectList.add(new Project());
        projectList.add(new Project());
        projectList.add(new Project());
        return  new Result(true,"操作成功",projectList);
    }


    @RequestMapping(value = "project.brand.getProjectDetai",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "通过项目ID查找拓展需求以及项目信息",notes = "通过项目ID查找拓展需求以及项目信息")
    @ApiImplicitParam(name = "projectId",value = "项目ID",dataType = "java.util.string")
    public Result getExpandDetail(Integer projectId){
        Map<String,Object> data = new HashMap<String,Object>();
        data.put("brand",new Brand());
        //方法省略通过项目ID查找项目信息
        data.put("brandExpand",new Project());
        return  new Result(true,"操作成功",data);
    }


    @RequestMapping(value = "project.brand.moreProject",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查看更多的项目",notes = "查看更多的项目")
    public Result getMoreProjects(){
        Map<String,Object> data = new HashMap<String,Object>();
        List<Project> projectList = new ArrayList<Project>();
        projectList.add(new Project());
        projectList.add(new Project());
        data.put("projectList",projectList);
        Map<String,Object> sysEnums = new HashMap<>();
        sysEnums.put("projectArea",systemUtil.getSysParaByType("projectArea"));
        sysEnums.put("merchantNeeding",systemUtil.getSysParaByType("merchantNeeding"));
        data.put("sysEnum",sysEnums);
        return  new Result(true,"操作成功",data);
    }


}
